﻿using System;
using System.Configuration;

namespace Middleware.Naming
{
    [Serializable]
    public class NamingStub : StubBase, INaming
    {
        public NamingStub()
            : base(new RemoteObject(false) {
                ObjectID = NamingImpl.DEAFULT_ID,
                IP = ConfigurationManager.AppSettings["naming-ip"],
                Port = Convert.ToInt32(ConfigurationManager.AppSettings["naming-port"])
            }) {
        }

        #region INaming Members

        public void Bind(string serviceName, RemoteObject remoteObject) {
            base.Execute("Bind", false, new object[] { serviceName, remoteObject });
        }

        public void Unbind(int id) {
            base.Execute("Unbind", false, new object[] { id });
        }

        public object Lookup(string serviceName) {
            return base.Execute("Lookup", true, new object[] { serviceName });
        }

        #endregion
    }
}
